<template>
  <div>
    <el-drawer
      title=""
      :visible.sync="drawer"
      :direction="direction"
      :before-close="handleClose"
      custom-class="drawer-info"
    >
      <div class="info-item">
        <h5 class="from-title">基本信息</h5>
        <div class="form-item">
          <label class="form-item-label">pc图片:</label>
          <div class="form-item-content">
            <img :src="objInfo.pcImage" v-if="objInfo.pcImage" />
          </div>
        </div>
        <div class="form-item">
          <label class="form-item-label">app图片:</label>
          <div class="form-item-content">
            <img :src="objInfo.appImage" v-if="objInfo.appImage" />
          </div>
        </div>
        <div class="form-item">
          <label class="form-item-label">跳转链接:</label>
          <div class="form-item-content">{{ objInfo.url }}</div>
        </div>
        <div class="form-item">
          <label class="form-item-label">标签:</label>
          <div class="form-item-content">
            <div class="tag">
              <el-tag
                v-for="item in tagArray"
                :key="item"
                style="margin-right: 4px"
                >{{ item }}</el-tag
              >
            </div>
          </div>
        </div>
        <div class="form-item">
          <label class="form-item-label">排序:</label>
          <div class="form-item-content">{{ objInfo.sort }}</div>
        </div>
      </div>
    </el-drawer>
  </div>
</template>
<script>
import { cmsbannerInfo } from "@/api/cms/cmsbanner.js";

export default {
  data() {
    return {
      drawer: true,
      direction: "rtl",
      objInfo: {},
      tagArray: []
    }
  },
  created() {
  },
  methods: {
    init(id) {
      if (id) {
        cmsbannerInfo(id).then(res => {
          this.objInfo = res.data
          if (this.objInfo.tags) {
            this.tagArray = this.objInfo.tags.split(";");
          }
        })

      }
      this.drawer = true
    },
    // 关闭抽屉
    handleClose(done) {
      done()
    },
  },
}
</script>
<style scoped>
.from-title {
  margin-bottom: 20px;
  padding: 0 20px 20px 20px;
  font-size: 16px;
  color: #17233d;
  border-bottom: 1px solid #eee;
}
.info-item {
  margin-bottom: 40px;
}

.form-item {
  margin-bottom: 20px;
  font-size: 14px;
}
.form-item-label {
  text-align: right;
  float: left;
  width: 25%;
}
.form-item-content {
  margin-left: 30%;
  width: 70%;
}
</style>
